//
//  MessageCell.m
//  KiklinkApp
//
//  Created by LJC on 14-9-15.
//  Copyright (c) 2014年 Kiklink. All rights reserved.
//

#import "MessageCell.h"

#import "UIColor+hex.h"

@implementation MessageCell

- (void)awakeFromNib
{
    self.contentView.backgroundColor = [UIColor colorWithHexString:AppColor_BackGround];
    self.timeLabel.textColor = [UIColor colorWithHexString:AppColor_Text];
    self.detailLabel.textColor = [UIColor colorWithHexString:AppColor_Text];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)loadData
{
    self.timeLabel.text = @"2014-9-15";
    self.detailLabel.text = @"您的订单请在2014年9月15日之前付款，未付....啊啊啊啊啊";
}

- (void)loadData2
{
    self.timeLabel.text = @"2014-9-16";
    self.detailLabel.text = @"您的订单请在2014年9月16日之前付款，未付....哈哈哈哈哈";
}

- (void)loadDataWithMessage:(Message *)message
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"YYYY-MM-dd"];
    
    NSDate *messageDate = [NSDate dateWithTimeIntervalSince1970:(long long)(message.createtimelong/1000)];
    NSString *messageDateStr = [formatter stringFromDate:messageDate];
    
    self.timeLabel.text = messageDateStr;
    self.detailLabel.text = message.content;
}

+ (CGFloat)cellHeight:(Message *)message
{
    NSDictionary * attributedDic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14.0], NSFontAttributeName, nil];
    CGRect newDetailRect = [message.content boundingRectWithSize:CGSizeMake(ScreenWidth-20, 20000) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributedDic context:nil];
    
    return newDetailRect.size.height + 53;
}

@end
